package selenium;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.testng.Assert;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;

import java.util.concurrent.TimeUnit;

/**
 * Created by 1 on 27.06.2014.
 */
public class SamsungSearch {
    WebDriver driver= new FirefoxDriver();

    @BeforeClass

    public void setUp(){
        driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);

        driver.manage().window().maximize();
        driver.get("http://rozetka.com.ua/");
    }

    @Test
    public void searchTest(){
        WebElement searchField=driver.findElement(By.xpath(".//*[@id='body-header']/div[2]/div/div/div/div[2]/form/div[2]/div[1]/input"));
        searchField.sendKeys("Samsung G900H Galaxy S5 Black");
        WebElement buttonSearch = driver.findElement(By.xpath(".//*[@id='body-header']/div[2]/div/div/div/div[2]/form/div[1]/span/button"));
        buttonSearch.click();
        WebElement samsungLink=driver.findElement(By.xpath(".//*[@id='head_banner_container']/div[3]/div/div[1]/div/div/div[3]/div[1]/div[2]/div[1]/a"));
        Assert.assertEquals(samsungLink.getText().toString().contains("Samsung G900H Galaxy S5 Black"), true);
        samsungLink.click();
        WebElement searchText=driver.findElement(By.xpath(".//*[@id='head_banner_container']/div[3]/div/div[1]/div/div[1]/div/div[1]/div/div/div[4]/div[1]/div"));
        Assert.assertEquals(searchText.getText().toString().contains("Exynos 5422 (Quad 1.9 ГГц + Quad 1.3 ГГц)"),true);
    }

    @AfterClass
    public void tearDown(){
        driver.quit();
    }

}
